package com.seda.fdc.ejb.reports.pdfgenerator.lowagie.text;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.BaseFont;
 

public abstract class BaseFontFactory  extends com.lowagie.text.pdf.BaseFont{
	//public static final String AIRACOBRA_ALT ="font/Airacobra Alt.ttf"; 
	//public static final String ARIALUNI ="font/ARIALUNI.ttf"; 
	//public static final String BATANG_CHE ="font/batang.ttc,0"; 
	public static final String COURIER_NEW ="resources/font/cour.ttf"; 
	public static final String ARIAL ="resources/font/arial.ttf";
	public static final String OCRB_SEDA ="resources/font/ocrbseda.ttf";
	public static final String OCRB ="resources/font/OCRB.TTF";
	public static final String OCRB10PitchBT_Regular ="resources/font/ocr-b-10-pitch-bt.ttf";
	public static final String new_ArialT1_Bold_24 ="resources/font/soris896/new-ArialT1-Bold-24.afm";
	public static final String _601 ="resources/font/soris896/601.ttf";
	public static final String _779 ="resources/font/soris896/779.ttf";
	public static final String _arialbd ="resources/font/soris896/arial/arialbd.ttf";
	public static final String _arialbi ="resources/font/soris896/arial/arialbi.ttf";
	public static final String _ariali ="resources/font/soris896/arial/ariali.ttf";
	public static final String _ARIALN ="resources/font/soris896/arial/ARIALN.ttf";
	public static final String _ARIALNB ="resources/font/soris896/arial/ARIALNB.ttf";
	public static final String _ARIALNBI ="resources/font/soris896/arial/ARIALNBI.ttf";
	public static final String _ARIALNI ="resources/font/soris896/arial/ARIALNI.ttf";
	public static final String _ariblk ="resources/font/soris896/arial/ariblk.ttf";
	
	
//	public static final String ArialNarrow_Bold ="resources/font/soris896/ArialNarrow-Bold.ttf";
//	public static final String ArialT1_Bold ="resources/font/soris896/ArialT1-Bold.ttf"; 
//	public static final String ArialT1 ="resources/font/soris896/ArialT1.ttf"; 
//	
//	
	
	
	
	public static BaseFont createFont(String name, String encoding, boolean embedded) throws DocumentException, IOException{ 
		
		ByteArrayOutputStream buffer =  new ByteArrayOutputStream();
		
		InputStream isInputStream = BaseFontFactory.class.getResourceAsStream(name);
		 
		int nRead;
		byte[] data = new byte[16384];
		
		while ((nRead = isInputStream.read(data, 0, data.length)) != -1) {
		  buffer.write(data, 0, nRead);
		}
		
		buffer.flush();  
		
		byte[] ttfAfm = buffer.toByteArray();
		   
		BaseFont result =  BaseFont.createFont( name,
				                 encoding,
				                 embedded,
				                 true,
				                 ttfAfm,
				                 null);
		
		isInputStream.close();
		
		return result;

	}
	 
	
}

